package com.wlcorp.forcazamis.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts.action.ActionServlet;

import com.wlcorp.forcazamis.sys.util.AppConstant;


public class SubActionServlet extends ActionServlet {
	private static final long serialVersionUID = 1L;
	private final Logger log = Logger.getLogger(this.getClass().getName());
	public void service(ServletRequest request, ServletResponse response)
			throws ServletException, IOException {
		try {
			//权限控制，待写
			super.service(request, response);
		} catch (Exception ex) {
			log.error("catch exceptioin:",ex);
			String errorPath = "error.jsp";
			HttpServletRequest httpRequest = (HttpServletRequest)request;
			request.setAttribute(AppConstant.MESSAGE,"系统出错!");
			String url = httpRequest.getRequestURI();
			int urlLayerCount = url.split("/").length;
			if(urlLayerCount > 3){
				for(;urlLayerCount > 3;urlLayerCount--){
					errorPath = "../" + errorPath;
				}
			}
			request.getRequestDispatcher(errorPath).forward(request,response);
		} 
	}
}
